﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Models;
using BLL;

namespace CSMF
{
    public partial class NewsList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindNews();
            }
        }

        protected void BindNews()
        {
            IList<NewsInfo> news = NewsInfoManager.GetNewsInfosByTypeID("2,3");
            this.AspNetPager1.RecordCount = news.Count;
            this.AspNetPager1.PageSize = 5;
            PagedDataSource pds = new PagedDataSource();
            pds.DataSource = news;
            pds.AllowPaging = true;
            pds.PageSize = 5;
            pds.CurrentPageIndex = this.AspNetPager1.CurrentPageIndex - 1;
            rptNews.DataSource = pds;
            rptNews.DataBind();
        }

        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
            BindNews();
        }

    }
}
